home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagd_f.zip / EGAVGA.SWG / 0167_New Optimized UModeQ Unit.pas < prev    next >
Pascal/Delphi Source File  |  1995-03-03  |  4KB  |  131 lines

  1.  
  2. {
  3. >    how ever i know that the ET3000 use diference ways to get your
  4. > modes so this mite be your trouble..
  5. no, it can't, cause the mode is actually set and works, but some single lines
  6. (!) just don't work (and they change if I run the program twice or more) - so
  7. this screen is 256 lines high, and for example lines 3, 180, 185 and 200 are
  8. let's say gray - any idea why?  (the amount of lines and which lines seem to be
  9. totally random)
  10.  
  11. (* Original code by Bas van Gaalen.         *)
  12. (* Modified for no vertical overscan        *)
  13. (* and converted to unit by Antonio Sanchez *)
  14. }
  15. unit umodeq;
  16.  
  17. interface
  18. type
  19.   twrec=record reg:word; func,data:byte; end;
  20.   twarr=array[0..24] of twrec;
  21.  
  22. const
  23.   vidseg:word=$a000;
  24.  
  25.   tweak:twarr=(
  26.     (reg:$03d4; func:$00; data:$5f), { hor. total }
  27.     (reg:$03d4; func:$01; data:$3f), { hor. display enable end }
  28.     (reg:$03d4; func:$02; data:$40), { blank start }
  29.     (reg:$03d4; func:$03; data:$82), { blank end }
  30.     (reg:$03d4; func:$04; data:$4e), { retrace start }
  31.     (reg:$03d4; func:$05; data:$9a), { retrace end }
  32.     (reg:$03d4; func:$06; data:$23), { vertical total }
  33.     (reg:$03d4; func:$07; data:$b2), { overflow register }
  34.     (reg:$03d4; func:$08; data:$00), { preset row scan }
  35.     (reg:$03d4; func:$09; data:$61), { max scan line/char heigth }
  36.     (reg:$03d4; func:$10; data:$0a), { ver. retrace start }
  37.     (reg:$03d4; func:$11; data:$ac), { ver. retrace end }
  38.     (reg:$03d4; func:$12; data:$ff), { ver. display enable end }
  39.     (reg:$03d4; func:$13; data:$20), { offset/logical width }
  40.     (reg:$03d4; func:$14; data:$40), { underlinde location }
  41.     (reg:$03d4; func:$15; data:$07), { ver. blank start }
  42.     (reg:$03d4; func:$16; data:$17), { ver. blank end }
  43.     (reg:$03d4; func:$17; data:$a3), { mode control }
  44.     (reg:$03c4; func:$01; data:$01), { clock mode register }
  45.     (reg:$03c4; func:$04; data:$0e), { memory mode register }
  46.     (reg:$03ce; func:$05; data:$40), { mode register }
  47.     (reg:$03ce; func:$06; data:$05), { misc. register }
  48.     (reg:$03c0; func:$10; data:$41), { mode control }
  49.     (reg:$3c2;  func:$0;  data:$e3), (* newly added *)
  50.     (reg:$3c0;  func:$13; data:$0)); (* newly added *)
  51.  
  52. procedure setpal(col,r,g,b : byte);
  53. procedure initvga;
  54. procedure inittxt;
  55. procedure openregs;
  56. procedure closeregs;
  57. procedure setmodeq;
  58. procedure putpixel(x,y,c:byte);
  59. procedure fillscreen;
  60.  
  61. implementation
  62.  
  63. procedure setpal(col,r,g,b : byte);assembler; asm
  64.   mov dx,03c8h; mov al,col; out dx,al; inc dx; mov al,r; out dx,al
  65.   mov al,g; out dx,al; mov al,b; out dx,al; end;
  66.  
  67. procedure initvga; assembler; asm mov ax,13h; int 10h; end;
  68. procedure inittxt; assembler; asm mov ax,3; int 10h; end;
  69.  
  70. procedure openregs; assembler; asm
  71.   mov dx,03d4h; mov al,11h; out dx,al; inc dx; in al,dx; and al,7fh
  72.   mov ah,al; mov al,11h; dec dx; out dx,ax; end;
  73.  
  74. procedure closeregs; assembler; asm
  75.   mov dx,03d4h; mov al,11h; out dx,al; inc dx; in al,dx; or al,80h
  76.   mov ah,al; mov al,11h; dec dx; out dx,ax; end;
  77.  
  78. procedure setmodeq;
  79. var i:byte;
  80.     dummy : byte;
  81. begin
  82.   initvga;
  83.   openregs;
  84.   for i:=0 to 24 do
  85.     with tweak[i] do
  86.     begin
  87.       IF reg=$3c0
  88.       then begin
  89.             dummy:=port[$3da];     { reset read/write flip-flop }
  90.             port[$3c0]:= func or $20; { ensure vga output is enabled }
  91.             port[$3c0]:= data;
  92.            end
  93.       else if (reg=$3c2) or (reg=$3c3)
  94.        then port[reg]:=data   {  directly to the port  }
  95.       else begin
  96.             port[reg]:=func;  {  index to port  }
  97.             port[reg+1]:=data;{  value to port+1  }
  98.            end;
  99.     end;
  100.   closeregs;
  101. end;
  102.  
  103. procedure putpixel(x,y,c:byte); assembler;
  104. asm
  105.   mov es,vidseg
  106.   mov bh,[y]
  107.   mov bl,[x]
  108.   mov al,[c]
  109.   mov [es:bx],al
  110. end;
  111.  
  112. procedure fillscreen; assembler;
  113. asm
  114.   mov es,vidseg
  115.   xor cx,cx
  116.  @loop:
  117.   mov di,cx
  118.   mov al,cl
  119.   add al,ch
  120.   mov [es:di],al
  121.   inc cx
  122.   jnz @loop
  123. end;
  124. end.
  125.  
  126. {
  127. well, I have no simple example for that unit now, but for example just fill the
  128. screen each line with a different color, and you'll see...  (BTW, works on a
  129. ET4000 and on my new Cirrus Logic-based card...)
  130. }
  131.